<?
require("config.php");

$location_status .= " | Edit";

$show_backnav = "menu";

require($rela_path . "bin/country.php");

$menutype = 2;

if (NULL!=$action){

	$dir = $table . "/";

	if ($Picture1) myUpload($Picture1,$Picture1_name,$dir);
	if ($Picture2) myUpload($Picture2,$Picture2_name,$dir);

	if ($Picture1_name == null) $Picture1_name = $bk_Picture1;
	if ($Picture2_name == null) $Picture2_name = $bk_Picture2;


	if ($sm_Picture1) myUpload($sm_Picture1,"sm_" . $Picture1_name,$dir);
	if ($sm_Picture2) myUpload($sm_Picture2,"sm_" . $Picture2_name,$dir);


	if ($remove_1=="ture") $Picture1_name=NULL;
	if ($remove_2=="ture") $Picture2_name=NULL;


   $field = array(
	"code",
	"name",
	"email",
	"phone",
	"picture1",
	"picture2",
	"brief",
	"details",
	"status",
	"publish_date",
	"sex",
	"duty",
	"accept",
	"email_alert",
	"aorder",
	);


   $content = array(
	$Code,
	$Name,
	$Email,
	$Phone,
	$Picture1_name,
	$Picture2_name,
	$Brief,
	$Details,
	$Status,
	"$myYear-$myMonth-$myDay",
	$Sex,
	$Duty,
	$Accept,
	$Email_alert,
	$aorder,
	);

   $exp = "id='$id'";

   myUpdate($table,$field,$content,$exp);


   if ($Name!==$old_Name){

   $field = array(
	"trainer",
	);


   $content = array(
	$Name,
	);

   $exp = "trainer='$old_Name'";

   myUpdate("course_activities",$field,$content,$exp);
   myUpdate("course_trainer_sharing",$field,$content,$exp);

   }


   header("location:" . $rela_path . "share/msg.php?v=722&Start_Num=" . $Start_Num);

   exit();

}


$Query = "select 
	code,
	name,
	email,
	phone,
	picture1,
	picture2,
	brief,
	details,
	status,
	publish_date,
	sex,
	duty,
	accept,
	email_alert ,
	aorder
from $table where id='$id' Limit 1";
$r = myQuery($Query);




	$Code=		$r[0][0];
	$Name=	$r[0][1];
	$Email=	$r[0][2];
	$Phone=	$r[0][3];
	$Picture1=	$r[0][4];
	$Picture2=	$r[0][5];
	$Brief=	$r[0][6];
	$Details=	$r[0][7];
	$Status=	$r[0][8];
	$publish_date=	$r[0][9];
	$Sex=	$r[0][10];
	$Duty=$r[0][11];
	$Accept=$r[0][12];
	$Email_alert =$r[0][13];
$aorder=$r[0][14];
require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

?>

<form action="" method="post" enctype="multipart/form-data" name="form1">
<!--hidden filed-->
<input name="action" type="hidden" value="edit">
<input name="Code" type="hidden" value="<?print($Code)?>">

<input name="bk_Picture1" type="hidden" value="<?print($Picture1)?>">
<input name="bk_Picture2" type="hidden" value="<?print($Picture2)?>">

<input name="old_Name" type="hidden" value="<?print($Name)?>">

  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right"> <input name="image" type="image" onclick="Redirect('menu.php',1);return false;" src="../../images/bt_cancel.gif" width="78" height="23"> 
        <input name="image" type="image" src="../../images/bt_save.gif" width="76" height="22"  <?print($active)?>> 
      </td>
    </tr>
  </table>
  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right">&nbsp; </td>
    </tr>
    <tr> 
      <td><table border="0">


	  <!--
          <tr>
            <td>&nbsp;</td>
            <td><div align="right"><a href="../trainer_activities/menu.php?label=<?=$Name?>">Activities</a> | <a href="../trainer_sharing/menu.php?label=<?=$Name?>">Sharing</a></div></td>
          </tr>
-->
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Code :</td>
            <td> <?print($Code)?> </td>
          </tr>
          <tr> 
            <td class="tdheader">Name :</td>
            <td> <input class="text" name="Name" type="text" value="<?echo $Name?>" size="50"> 
            </td>
          </tr>

          <tr> 
            <td class="tdheader">Sex :</td>
            <td>
			
<?

$sourceData = array(
	"Mr.",
	"Ms.",
	"Mrs.",
);

$sourceLabel = $sourceData;

FFPCheckBox("Sex",$Sex,$sourceData,$sourceLabel)

?>


            </td>
          </tr>


          <tr> 
            <td class="tdheader">Status :</td>
            <td>
			
<?

$sourceData = array(
	"0",
	"1",
);

$sourceLabel = array(
	"Trainer",
	"Coach",
);

FFPCheckBox("Duty",$Duty,$sourceData,$sourceLabel)

?>


            </td>
          </tr>




          <tr> 
            <td class="tdheader">Coaching Booking :</td>
            <td>
			
<?

$sourceData = array(
	"0",
	"1",
);

$sourceLabel = array(
	"Yes",
	"No",
);

FFPCheckBox("Accept",$Accept,$sourceData,$sourceLabel)

?>


            </td>
          </tr>
          <tr> 
            <td class="tdheader">Booking Alert :</td>
            <td>
			
<?

$sourceData = array(
	"1",
	"0",
);

$sourceLabel = array(
	"Yes",
	"No",
);

FFPCheckBox("Email_alert",$Email_alert,$sourceData,$sourceLabel);

?>


            </td>
          </tr>


          <tr> 
            <td class="tdheader">E-mail :</td>
            <td><input class="text" name="Email" type="text" value="<?echo $Email?>" size="50"></td>
          </tr>
          <tr> 
            <td class="tdheader">Contact Phone :</td>
            <td><input class="text" name="Phone" type="text" value="<?echo $Phone?>" size="50"></td>
          </tr>




          <tr> 
            <td class="tdheader">Picture 1</td>
            <td>
			
			<?removeImage($Picture1,"remove_1")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture1,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture1" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture1,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture1" size="40">
			<br><br>


            </td>
          </tr>



          <tr> 
            <td class="tdheader">Picture 2</td>
            <td>
			
			<?removeImage($Picture2,"remove_2")?>
			
			<!--<br><b>(Normal Picture)</b><br>-->
			<?loadImage($Picture2,$rela_path . $PIC_DIR . "$table/")?> 
			<input type="file" class="text" name="Picture2" size="40">

			<br><b>(Smaller Picture)</b><br>
			<?loadSmallImage($Picture2,$rela_path . $PIC_DIR . "$table/")?>
			<input type="file" class="text" name="sm_Picture2" size="40">
			<br><br>


            </td>
          </tr>







          <tr> 
            <td class="tdheader">Brief :</td>
            <td><textarea class="text" name="Brief" cols="50" rows="4"><?echo $Brief?></textarea></td>
          </tr>
          <tr> 
            <td class="tdheader">Details :</td>
            <td> <textarea class="text" name="Details" cols="60" rows="30"><?echo $Details?></textarea> 
            </td>
          </tr>
          <tr> 
            <td class="tdheader">Publish :</td>
            <td> 
              <?

$sourceData = array(
  "Yes",
  "No",
  );

 $sourceLabel=$sourceData;

$boxName="Status";

$value=$Status;

FFPCheckBox("Status",$Status,$sourceData,$sourceLabel);

?>
          </tr>
          <tr> 
            <td class="tdheader">Publishing Date : </td>
            <td><?print(FFPtime($publish_date))?></td>
          </tr>
          <tr>
            <td class="tdheader">Appearance Order :</td>
            <td>
              <input name="aorder" type="text" class="text" id="aorder" value="<?=$aorder?>" size="4" maxlength="4">
    (smaller number on top) </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
      </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
    </tr>
  </table>
  <table width="95%" border="0" align="center">
    <tr> 
      <td align="right"> <input name="image2" type="image" onclick="Redirect('menu.php',1);return false;" src="../../images/bt_cancel.gif" width="78" height="23"> 
        <input name="image2" type="image" src="../../images/bt_save.gif" width="76" height="22" <?print($active)?>> 
      </td>
    </tr>
  </table>
</form>
<?
require($rela_path . "inc/footer.php");
?>

